package com.od.controller;

import com.od.entity.Qualification;
import com.od.service.QualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("qualification")
@CrossOrigin
public class QualificationController {

    @Autowired
    private QualificationService qualificationService;

    @RequestMapping("getQualificationById")
    @ResponseBody
    public List<Qualification> getQualificationById(int qualificationResume) {
        return qualificationService.getQualificationById(qualificationResume);
    }

    @RequestMapping("addQualification")
    @ResponseBody
    public int addQualification(@RequestBody Qualification qualification) {
        System.out.println(qualification);
        return qualificationService.addQualification(qualification);
    }

    @RequestMapping("updateQualificationById")
    @ResponseBody
    public int updateQualificationById(@RequestBody Qualification qualification) {
        System.out.println(qualification);
        return qualificationService.updateQualificationById(qualification);
    }

    @RequestMapping("deleteQualificationById")
    @ResponseBody
    public int deleteQualificationById(@RequestBody Map<String, Integer> qualificationData) {
        int qualificationId = qualificationData.get("qualificationId");
        return qualificationService.deleteQualificationById(qualificationId);
    }

}
